package com.day21.test2;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class logAspect {

/*    @Pointcut("execution(* HelloService.*(..))")
    public void any()
    {

    }*/


/* @Before("execution(* HelloService.*(..))")
    public void before()
    {
        System.out.println("before .. ");
    }
    和下面的等价
    */

/*   @Before("any()")*/
    public void before()
    {
        System.out.println("before .. ");
    }

    /*@After("execution(* HelloService.*(..))")
    public void after(){
        System.out.println("after .....");
    }
*/

    /*
    * 获取HelloService()的返回值，并且使用result来接收
    * */
/*    @AfterReturning(value = "execution(* HelloService.*(..))",returning = "result")
    public void afterRetruning(JoinPoint joinPoint,Object result){
        System.out.println(result);
    }*/
/*
    @AfterThrowing(value = "execution(* HelloService.*(..))",throwing = "e")
    public void afterThrowing(JoinPoint joinPoint,Exception e){
        e.printStackTrace();

    }

    @Around("execution(* HelloService.*(..))")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("1");
        Object result = proceedingJoinPoint.proceed();
        System.out.println("2");
        return result;
    }*/


}
